package cn.panda.edu.controller;

import cn.panda.edu.model.Enter;
import cn.panda.edu.service.EnterService;
import cn.panda.edu.util.Constant;
import cn.panda.edu.util.ResultDataUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@Api(description="报名审核")
@RequestMapping(value="api/admin")
public class ManageEnterController {

	@Autowired
	private EnterService enterService;
	
	
	/**
	 * 
	* @Title: QueryStudentFy 
	* @Description: TODO(查询报名学生) 
	* @param pageIndex
	* @return
	* Map<String,Object>
	 */
	@ApiOperation(value="查询报名学生")
	@ApiImplicitParams({
		@ApiImplicitParam(name="pageIndex", value="当前页码", required=true, dataType="int", paramType="form"),
		@ApiImplicitParam(name="enterName", value="报名人姓名", required=false, dataType="string", paramType="form")})
	@RequestMapping(value="queryEnterFy",method=RequestMethod.POST)
	public Object queryEnterFy(Integer pageIndex, String enterName){
		PageInfo<Enter> pageInfo = enterService.selectByTranStatus(pageIndex, Constant.PAGE_SIZE,  enterName);
		return ResultDataUtil.resData(200, "", pageInfo) ;
		
	}
	@ApiOperation(value="审核报名学生")
	@ApiImplicitParams({
		@ApiImplicitParam(name="enterId",value="报名ID",required=true,dataType="int",paramType="form"),
		@ApiImplicitParam(name="enterDelete",value="审核状态",required=true,dataType="int",paramType="form")
	})
	@RequestMapping(value="queryEnterUp",method=RequestMethod.POST)
	public Map<String, Object> queryEnterUp(Enter enter){
		Map<String, Object> map = new HashMap<>();
		int result = enterService.updateByPrimaryKeySelective(enter);
		if (result > 0) {
			map = ResultDataUtil.resData(200, "审核成功！", null) ;
		}else {
			map = ResultDataUtil.resData(500, "审核失败！", null) ;
		}
		
		return map;
	}
}
